/*
 * Copyright 2011 The Rusted Roof, LLC.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package org.proteusframework.platformservice.persistence.c14n;

/**
 * Standard package-agnostic conversion routines for extended data types capable of turning an <code>Object</code> into
 * a <code>byte[]</code>, and vice-versa.
 *
 * @author Tacoma Four
 */
public interface IC14NHandler
{
    String PACKED_BLOB_PREFIX = "[->]";
    String PACKED_BLOB_SUFFIX = "[<-]";

    int PACKED_BLOB_PREFIX_LEN = PACKED_BLOB_PREFIX.length();
    int PACKED_BLOB_SUFFIX_LEN = PACKED_BLOB_SUFFIX.length();

    /**
     * Converts an object to a canonicalized <code>byte[]</code> representation.
     *
     * @param object Object to canonicalize
     * @return byte[] representation of the object
     */
    byte[] toC14N(Object object);


    /**
     * Converts a canonicalized <code>byte[]</code> back into its <code>Object</code> representation.
     *
     * @param bytes Canonicalized bytes
     * @return Object represented by the canonicalized byte array
     */
    Object fromC14N(byte[] bytes);
}
